LUA REGISTER FUNCTION
This command allows you to register a custom dbpro user function and make it available from within your scripts (see the DBPro.Call help).
The first parameter is the memory address of the function you would like to register.
The second parameter is the function name. It is case-sensitive and the first letter must be upper-case, and it must not have any spaces. This has not necessarily to be the same as the dbpro function name. But you must specify this name again when using DBPro.Call().
The third parameter specifies the types of the arguments the dbpro user command needs. This is done using a letter for each type. If the command returns something, then the first letter is the return type. If the command has no parameters and no return type, specify this with the empty string "".
Types are: S for String, L for Integer, D for Dword, F for Float. See also the help for the DBPro.Call function.
If the user command returns something, then specify this using the forth parameter with a 1, or a 0 otherwise. And remember to define the return type in the params string in the first letter.
The fifth and last parameter is_plugin_function is 0 for dbpro user functions, but has to be 1 if the function ptr points to a plugin function (a plugin or dbpro dll). However, if you want to call a function of a dll that is not using the dbpro string standard (e.g. windows dlls or non-plugin-dlls), then you also need to specify a 0.
Example: (there is also an example source code register_functions.dba) You have the following dbpro user function:
Function printHelloWorld(your_name as String, your_age as Integer)
Then you register it using this command and the name "PrintHelloWorld" (note the first upper-case letter), the params String: "SL", and indicating no return value with the forth parameter as 0. The last parameter would be 0 too, because it is a dbpro user function.
How to get the memory address of your function? There are plugins available for that, e.g. IanMs Matrix1 Utilities #20 has a function called GET PTR TO FUNCTION() and GET PTR TO DLL FUNCTION().
SYNTAX
LUA REGISTER FUNCTION function_ptr as Dword, function_name as String, parameter_types as String, has_return_value as Integer, is_plugin_function as Integer
RELATED INFO
LUA command menu
Index
EXAMPLE
Showcase-example 1
Showcase-example 2